#coding=utf-8
#@Time:2020/5/15 11:48 AM
#@Author:希哥
#@File:dingding.py

import requests
import json

class DingTalk_Base:
    def __init__(self):
        self.__headers = {'Content-Type': 'application/json;charset=utf-8'}
        self.url = 'https://oapi.dingtalk.com/robot/send?access_token=8a954d405fa77867f4b936c941c758471c8714e1a816bf67a89279991cd221b9'
    def send_msg(self,text):
        json_text = {
            "msgtype": "text",
            "text": {
                "content": text
            },
            "at": {
                "atMobiles": [
                    ""
                ],
                "isAtAll": False
            }
        }
        return requests.post(self.url, json.dumps(json_text), headers=self.__headers).content

if __name__ == '__main__':
    ding = DingTalk_Base()
    ding.send_msg('任务提示：信不信我用它来跟你聊天？')